//
//  ActivitiesTableViewCell.m
//  UI_豆瓣
//
//  Created by dllo on 15/10/26.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ActivitiesTableViewCell.h"
#import "AppTools.h"
#import "UIImageView+WebCache.h"
@interface ActivitiesTableViewCell ()

@property (nonatomic, retain)UILabel *titleLabel;
@property (nonatomic, retain)UILabel *typeLabel;
@property (nonatomic, retain)UILabel *hobbyLabel;
@property (nonatomic, retain)UILabel *joinLabel;


@end

@implementation ActivitiesTableViewCell

- (void)dealloc
{
    [_activities release];
    [_joinLabel release];
    [_hobbyLabel release];
    [_typeLabel release];
    [_timeLabel release];
    [_titleLabel release];
    [_joinData release];
    [_placeData release];
    [_typeData release];
    [_hobData release];
    [_litImageView3 release];
    [_litImageView2 release];
    [_litImageView1 release];
    [_pictureImageView release];
    [_middleImageView release];
    [_bigImageView release];
    [super dealloc];
}



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}


-(void)createCell
{
    
    self.bigImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 10, 345, 160)];
//    self.bigImageView.backgroundColor = [UIColor yellowColor];
    self.bigImageView.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    [self.contentView addSubview:self.bigImageView];
    [_bigImageView release];
    
    
    self.middleImageView = [[UIImageView alloc]initWithFrame:CGRectMake(2, 30, 341, 120)];
//    self.middleImageView.backgroundColor = [UIColor whiteColor];
    self.middleImageView.image = [UIImage imageNamed:@"bg_share_large.png"];
    [self.bigImageView addSubview:self.middleImageView];
    [_middleImageView release];
    
    
    //图片
    self.pictureImageView = [[UIImageView alloc]initWithFrame:CGRectMake(245, 5, 88, 108)];
    self.pictureImageView.backgroundColor = [UIColor yellowColor];
    [self.middleImageView addSubview:self.pictureImageView];
    [_pictureImageView release];
    //裁掉view的边界
    self.pictureImageView.layer.masksToBounds = YES;
    //设置半径
    self.pictureImageView.layer.cornerRadius = 10;
    
    
    
    //标题
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 320, 20)];
//    self.titleLabel.backgroundColor = [UIColor yellowColor];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [self.bigImageView addSubview:self.titleLabel];
    [_titleLabel release];
    
    
    
    
    //时间图标
    self.litImageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(10, 8, 16, 16)];
//    self.litImageView1.backgroundColor = [UIColor cyanColor];
    self.litImageView1.image = [UIImage imageNamed:@"icon_date.png"];
    [self.middleImageView addSubview:self.litImageView1];
    [_litImageView1 release];
    
    
    //时间显示
    self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 8, 210, 16)];
    self.timeLabel.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.timeLabel];
    [_timeLabel release];
    
    
    
    
    
    //地点图标
    self.litImageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(10, 32, 16, 16)];
//    self.litImageView2.backgroundColor = [UIColor cyanColor];
    self.litImageView2.image = [UIImage imageNamed:@"icon_spot.png"];
    [self.middleImageView addSubview:self.litImageView2];
    [_litImageView2 release];
    
    //地点显示
    self.placeData = [[UILabel alloc]initWithFrame:CGRectMake(30, 32, 210, 16)];
//    self.placeData.backgroundColor = [UIColor yellowColor];
    self.placeData.font = [UIFont systemFontOfSize:12];
    self.placeData.numberOfLines = 0;
    [self.middleImageView addSubview:self.placeData];
    [_placeData release];
    
    
    
    
    //类型图标
    self.litImageView3 = [[UIImageView alloc]initWithFrame:CGRectMake(10, 56, 16, 16)];
//    self.litImageView3.backgroundColor = [UIColor cyanColor];
    self.litImageView3.image = [UIImage imageNamed:@"icon_catalog.png"];
    [self.middleImageView addSubview:self.litImageView3];
    [_litImageView3 release];
    
    //类型:
    self.typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 56, 40, 16)];
    self.typeLabel.text = @"类型:";
    self.typeLabel.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.typeLabel];
    [_typeLabel release];
    
    //类型显示
    self.typeData = [[UILabel alloc]initWithFrame:CGRectMake(60, 56, 160, 16)];
//    self.typeData.backgroundColor = [UIColor yellowColor];
    self.typeData.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.typeData];
    [_typeData release];
    
    
    
    
    //感兴趣:
    self.hobbyLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 90, 50, 20)];
//    self.hobbyLabel.backgroundColor = [UIColor orangeColor];
    self.hobbyLabel.text = @"感兴趣:";
    self.hobbyLabel.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.hobbyLabel];
    [_hobbyLabel  release];
    
    //感兴趣人数
    self.hobData = [[UILabel alloc]initWithFrame:CGRectMake(55, 90, 50, 20)];
    self.hobData.textColor = [UIColor redColor];
    self.hobData.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.hobData];
    [_hobData release];
    
    
    
    
    //参加:
    self.joinLabel = [[UILabel alloc]initWithFrame:CGRectMake(130, 90, 40, 20)];
//    self.joinLabel.backgroundColor = [UIColor orangeColor];
    self.joinLabel.text = @"参加:";
    self.joinLabel.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.joinLabel];
    [_joinLabel release];
    
    //参加人数
    self.joinData = [[UILabel alloc]initWithFrame:CGRectMake(165, 90, 50, 20)];
    self.joinData.textColor = [UIColor redColor];
    self.joinData.font = [UIFont systemFontOfSize:12];
    [self.middleImageView addSubview:self.joinData];
    [_joinData release];
    
    
}

-(void)setActivities:(ActivitesList *)activities
{
    if (_activities != activities) {
        [_activities release];
        _activities = [activities retain];
    }
    
    self.titleLabel.text = self.activities.title;
    self.placeData.text = self.activities.address;
    self.typeData.text = self.activities.category_name;
    
    //截取时间字符串
    NSString *str1 = [self.activities.begin_time substringWithRange:NSMakeRange(5, 11)];
    NSString *str2 = [self.activities.end_time substringWithRange:NSMakeRange(5, 11)];
    NSString *str = [NSString stringWithFormat:@"%@ -- %@",str1,str2];
    self.timeLabel.text = str;
    
    self.hobData.text = [NSString stringWithFormat:@"%@",self.activities.participant_count];
    self.joinData.text = [NSString stringWithFormat:@"%@",self.activities.wisher_count];
    
//    NSLog(@"1111=====%@", self.activities.image_hlarge);
    
    NSURL *url = [NSURL URLWithString:self.activities.image_hlarge];
    
    [self.pictureImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"Monkey.png"]];
   
    
    
    //要有内容才能用   自适应内容
//    [self.placeData sizeToFit];
    }






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
